<?php
include('bootstrap.php');
$db = Db::getConnection();

$fields = array('country','state','age','experience','industry','employees','occupation','developers','team_size',
                'dep_sysadmin','dep_designer','dep_prodman','dep_qa','dep_support','dep_sales','dep_consultant','dep_customer','dep_finance','dep_hr',
                'mobile_iphone','mobile_ipad','mobile_android','mobile_andtab','mobile_bb','mobile_other','mobile_none',
                'prod_advert','prod_b2c','prod_b2b','prod_saas','prod_mobile','prod_consult','prod_grant','prod_other',
                'time_newdev','time_refactor','time_bugs','time_support','time_meetings','time_skills','time_surf','time_commute',
                'purch_1','purch_2','purch_3','purch_4','purch_5','purch_6','purch_7','ptype_1','ptype_2','ptype_3','ptype_4','ptype_5','ptype_6','budget',
                'tech_c','tech_cpp','tech_cs','tech_java','tech_javascript','tech_jquery','tech_jq','tech_node','tech_objc',
                'tech_php','tech_python','tech_ruby','tech_sql','tech_other',
                'exc_node','exc_haskell','exc_coffeescript','exc_dart','exc_typescript','exc_cpp11','exc_winrt','exc_redis','exc_mongodb',
                'exc_fs','exc_phonegap','os',
                'char_compensation','char_stock','char_goals','char_excitement','char_newtech','char_growth','char_space','char_team','char_structure',
                'char_control','char_workstation','char_autonomy','char_location','char_commute','char_hours','char_nights',
                'changejobs','satisfaction','compensation',
                'techprod_1','techprod_2','techprod_3','techprod_4','techprod_5','techprod_6','techprod_7','techprod_8','techprod_9','techprod_10',
                'techprod_11','techprod_12','techprod_13','techprod_14','techpurch',
                'advert_1','advert_2','advert_3','advert_4','advert_5','advert_6','advert_7',
                'so_rep','so_use1','so_use2','so_use3','so_use4');

$distinctChar= array();
$csv = fopen('survey.csv','r');
$respondentList = new RespondentList();
$ctr = 0;
while ($row = fgetcsv($csv)) {
  $keyedRow = array();
  foreach ($row as $key => $field) {
    $keyedRow[$fields[$key]] = $field;
  }
  $distinctChar[$keyedRow['char_compensation']]++;
  $distinctChar[$keyedRow['char_workstation']]++;
  $distinctChar[$keyedRow['char_stock']]++;
  $distinctChar[$keyedRow['char_commute']]++;
	$respondentList->createRespondent($keyedRow);
	$ctr++;
}
print $ctr.' respondents added';